package com.xcity.pomelo.response;

import java.util.Collections;
import java.util.List;

import com.xcity.game.common.Currency;
import com.xcity.game.item.ItemTemplate;
import com.xcity.game.shop.AbstractShopTemplate;
import com.xcity.game.shop.ShopType;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class ShopV2Response extends Response {

	public List<ShopV2> list = Collections.emptyList(); // 商店列表
	
	public static class ShopV2 {
		public ShopType type;
		public int cd; // 刷新cd(秒)
		public int refreshCost; // 刷新消耗钻石(0表示不需要刷新)
		public int refreshCount; // 剩余刷新次数
		public int refreshTotal; // 总共可刷新次数(0表示不需要刷新)
		public List<ShopItemV2> items = Collections.emptyList(); // 商品列表
	}
	
	public static class ShopItemV2/* extends ItemResponse*/ {
		public String id; // unique id
		public int count;
		public String name;
		public String icon;
		public String desc;
		public byte quality;
		
		public Currency currency;
		public int price;
		public int availableCount; // 可购数量（0表示已售罄, -1表示不限购）
		public static final int AVAILABLE_ENOUGH = -1;
		
		public ShopItemV2(AbstractShopTemplate template, Currency currency, int availableCount) {
			this.id = template.getUniqueId();
			this.count = template.getCount();
			ItemTemplate item = template.getItemTemplate();
			this.name = item.getName();
			this.icon = item.getIcon();
			this.desc = item.getDesc();
			this.quality = item.getQuality();
			
			this.currency = currency;
			this.price = template.getPrice();
			this.availableCount = availableCount;
		}
	}
	
	public ShopV2Response(int serial, List<ShopV2> list) {
		super(serial);
		this.list = list;
	}

}
